package com.yboot.module.system.model.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yboot.starter.mybatis.core.annotation.TableIndexes;
import com.yboot.starter.mybatis.core.annotation.UniqueIndex;
import com.yboot.starter.common.core.web.validation.InsertGroup;
import com.yboot.starter.common.core.web.validation.UpdateGroup;
import com.yboot.starter.mybatis.core.base.entity.BaseEntity;

import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;

/**
 * 用户表
 * @author yangcs
 * @date 2025-08-29
 */
@EqualsAndHashCode(callSuper = true)
@Data
@TableName("sys_user")
@TableIndexes(indexes = {
        @UniqueIndex(fieldNames = {"nickname"}, message = "名称不可重复")
})
public class SysUserEntity extends BaseEntity {

    private static final long serialVersionUID = 1L;

    /**
     * ID
     */
    @NotBlank(message = "id不能为空", groups = {UpdateGroup.class})
    private String id;
    /**
     * 用户名
     */
    @NotBlank(message = "username不能为空", groups = {InsertGroup.class, UpdateGroup.class})
    private String username;
    /**
     * 昵称
     */
    @NotBlank(message = "nickname不能为空", groups = {InsertGroup.class, UpdateGroup.class})
    private String nickname;
    /**
     * 密码
     */
    private String password;
    /**
     * 性别（0：未知；1：男；2：女）
     */
    @NotBlank(message = "gender不能为空", groups = {InsertGroup.class, UpdateGroup.class})
    private String gender;
    /**
     * 邮箱
     */
    private String email;
    /**
     * 手机号码
     */
    private String phone;
    /**
     * 头像
     */
    private String avatar;
    /**
     * 描述
     */
    private String description;
    /**
     * 状态（1：启用；2：禁用）
     */
    @NotBlank(message = "status不能为空", groups = {InsertGroup.class, UpdateGroup.class})
    private String status;
    /**
     * 是否为系统内置数据
     */
    @NotNull(message = "isSystem不能为空", groups = {InsertGroup.class, UpdateGroup.class})
    private Boolean isSystem;
    /**
     * 最后一次修改密码时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime pwdResetTime;
    /**
     * 部门ID
     */
    @NotBlank(message = "deptId不能为空", groups = {InsertGroup.class, UpdateGroup.class})
    private String deptId;
    /**
     * 删除标识
     */
    private String deleteFlag;
}
